import { DomEditor, IDomEditor, IModuleConf } from '@wangeditor/editor';


/**
 * 自定义tag标签
 * @param editor
 */
function withTag<T extends IDomEditor>(editor: T) {
  const { isInline, isVoid } = editor;
  const newEditor = editor;

  newEditor.isInline = elem => {
    const type = DomEditor.getNodeType(elem);
    if (type === 'tag') {
      return true;
    }
    return isInline(elem);
  }

  newEditor.isVoid = elem => {
    const type = DomEditor.getNodeType(elem)
    if (type === 'tag') {
      return true;
    }
    return isVoid(elem)
  }
  return newEditor;
}

export default withTag;
